# -*_ codeing=utf-8 -*-
# @Time: 2023/1/17 22:32
# @Author: foxhuty
# @File: translation_easy_version.py
# @Software: PyCharm
# @Based on python 3.10

from translate import Translator


def title_lines(f):
    def wrapper(*args, **kwargs):
        print("{0:#^55}".format("欢迎使用Huty简易英汉词典"))
        res = f(*args, **kwargs)
        print("{0:#^55}".format("程序结束，谢谢使用"))
        return res

    return wrapper


@title_lines
def translate_english_chinese():
    e_c = Translator(from_lang='EN-US', to_lang='ZH-CN')
    while True:
        content = input('please input what needs to be translated:')
        if len(content) == 0:
            break
        result = e_c.translate(content)
        print("{0:+^58}".format('单词信息如下'))
        print(result)
        print("{0:+^60}".format('按enter键结束'))


@title_lines
def translate_chinese_english():
    c_e = Translator(from_lang='ZH-CN', to_lang='EN-US')
    while True:
        content = input('please input what needs to be translated:')
        if len(content) == 0:
            break
        result = c_e.translate(content)
        print("{0:+^58}".format('单词信息如下'))
        print(result)
        print("{0:+^60}".format('按enter键结束'))


@title_lines
def translate_to_any(dest_lang):
    c_e = Translator(from_lang='EN-US', to_lang=dest_lang)
    while True:
        content = input('please input what needs to be translated:')
        if len(content) == 0:
            break
        result = c_e.translate(content)
        print("{0:+^58}".format('单词信息如下'))
        print(result)
        print("{0:+^60}".format('按enter键结束'))


if __name__ == '__main__':
    # translate_english_chinese()
    # translate_chinese_english()
    translate_to_any('ZH-CN')
